package com.jybd.live.controller;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.jybd.live.mapper.RecordMapper;
import com.jybd.live.model.Record;
import com.jybd.live.service.AliLiveService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/test")
public class TestController {

    private AliLiveService aliLiveService;
    private RecordMapper recordMapper;

    @Autowired
    public TestController(AliLiveService aliLiveService,RecordMapper recordMapper) {
        this.aliLiveService = aliLiveService;
        this.recordMapper = recordMapper;
    }

    @RequestMapping("/gogogo")
    public String index() {
//        String url = aliLiveService.getLiveRecordURL("002/record/jybd/001/2020-06-13-18-27-47_2020-06-13-19-27-47.mp4");
//        return url;
        Record record = recordMapper.selectByPrimaryKey(1);
        try {
            return new ObjectMapper().writeValueAsString(record);
        } catch (JsonProcessingException e) {
            e.printStackTrace();
        }
        return "error";
    }
}
